import { createStore } from "vuex";

export default createStore( {
  state: {
    get:() => {
      return localStorage.token || ''
    },
    set: val => {
      if ( val ) {
        localStorage.token = val;
      } else {
        localStorage.removeItem( 'token' );
      }
    }
  },
  getters: {},
  mutations: {
    SAVE_TOKEN: (state, payload) => {
      state.token = payload;
      localStorage.token = state.token;
    }
  },
  actions: {},
  modules: {}
})